#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

#include "IApp.hpp"

int main(void)
{
	CEng::IApp *myApp = new(std::nothrow) CEng::IApp("Tile Game");
	if (myApp == NULL) {
		std::cout << "Could not create a new application" << std::endl;
		return 1;
	}
	
	myApp->AddTexture("./resources/colors.png", "colors");
	myApp->AddSprite(sf::IntRect(0,0,40,40), "colors", "red");
	myApp->AddSprite(sf::IntRect(40,0,40,40), "colors", "blue");
	myApp->AddSprite(sf::IntRect(80,0,40,40), "colors", "green");

	sf::Sprite a = myApp->GetSprite("red");
	myApp->EditSprite(5.f, 10.f, "red");

	myApp->Run();

	
    return 0;
}


/*
    sf::RenderWindow window;
	sf::Event event;
	sf::Sprite colors[3];
	sf::Vector2u RenderSize;
	int i;
	

	
	std::cout << myApp->mTitle << std::endl;
	
	sf::Texture TileMap;
	if (!TileMap.loadFromFile("colors.png")) {
		std::cout << "Could not load TileMap" << std::endl;
		return -1;
	}
	
	colors[0].setTexture(TileMap);
	colors[0].setTextureRect(sf::IntRect(0,0,40,40));
	colors[1].setTexture(TileMap);
	colors[1].setTextureRect(sf::IntRect(40,0,40,40));
	colors[2].setTexture(TileMap);
	colors[2].setTextureRect(sf::IntRect(80,0,40,40));

	window.create(sf::VideoMode(800, 600), "My window");
	
	RenderSize = window.getSize();
	std::cout << "x = " << RenderSize.x << ", y = " << RenderSize.y << std::endl;
	
	colors[1].setPosition(100.f, 200.f);
	window.draw(colors[1]);
	
	colors[2].setPosition(200.f, 300.f);
	window.draw(colors[2]);
		
	for (i = 0; i < 20; i++) {
		colors[0].setPosition(0.f + (i * 40), 570.f);
		window.draw(colors[0]);
	}
	
	window.display();
	
    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
			switch (event.type) {
				case sf::Event::Closed:
					window.close();
					break;
				case sf::Event::KeyPressed:
					EventHandler::KeyPress(event.key, &window);
					break;
				default:
					break;
			}
        }
    }
*/